package com.dianmi.seckill.common.advice;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 公共业务异常。各业务子系统自定义业务异常需要继承该类
 * @author xieqiaofu
 * @date 2020/11/24
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ServiceException extends RuntimeException {

    private static final long serialVersionUID = 7501817751835579377L;

    private int code;

    private String message;

    public ServiceException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public ServiceException(ResponseCode code) {
        super(code.getMsg());
        this.code = code.getCode();
        this.message = code.getMsg();
    }

    public ServiceException(ResponseCode code, String message) {
        super(message);
        this.code = code.getCode();
        this.message = message;
    }
}
